// import 'package:flutter/material.dart';
//样式统一 IOS风格

import "package:flutter/cupertino.dart";
import 'package:jd_shop/page/tabs/CartPage.dart';
import 'package:jd_shop/page/tabs/ClassPage.dart';
import 'package:jd_shop/page/tabs/MyPage.dart';

import '../page/goods/GoodsDetail.dart';
import '../page/goods/SearchGoods.dart';
import '../page/login/Login.dart';
import '../page/pay/Pay.dart';
import '../page/setting/Setting.dart';
import '../page/tabs/HomePage.dart';
import '../page/video/VideoPage.dart';
import 'AppRoutes.dart';

Map routes = {
  AppRoutes.HOME_PAGE: (context) => const HomePage(),
  AppRoutes.CLASS_PAGE: (context) => const ClassPage(),
  AppRoutes.CART_PAGE: (context) => const CartPage(),
  AppRoutes.MY_PAGE: (context) => const MyPage(),
  AppRoutes.LOGIN: (context) => const Login(),
  AppRoutes.SEARCH_GOODS: (context, {arguments}) => SearchGoods(
        arguments: arguments,
      ),
  AppRoutes.GOODS_DETAIL: (context, {arguments}) => GoodsDetail(
        arguments: arguments,
      ),
  AppRoutes.PAY: (context, {arguments}) => Pay(
        arguments: arguments,
      ),
  AppRoutes.SETTING: (context, {arguments}) => Setting(),
  AppRoutes.VIDEO_PAGE: (context, {arguments}) => VideoPage(),
};

var onGenerateRoute = (RouteSettings settings) {
  final String? name = settings.name; //  /news 或者 /search
  final Function? pageContentBuilder = routes[name]; //  Function = (contxt) { return const NewsPage()}

  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = CupertinoPageRoute(builder: (context) => pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route = CupertinoPageRoute(builder: (context) => pageContentBuilder(context));

      return route;
    }
  }
  return null;
};
